<template>
	<!-- 购买记录 -->
	<view>
		<my-head title="购买记录" :right="false"></my-head>
		<view class="content" v-if="ListData.length>0">
			<view class="card" v-for="item in ListData">
				<view class="cardlist">
					<view class="cardbz">{{item.ServiceName}}</view>
					<view class="cardje">{{item.PaymentAmount}}元</view>
				</view>

				<view>
					<view class="cardtext">订单编号：{{item.OrderNo}}</view>
					<view class="cardtext">支付方式：{{item.PaymentMethodText}}</view>
					<view class="cardtext">支付时间：{{item.PaymentTime}}</view>
				</view>

			</view>
			<u-loadmore :status="status" />
		</view>
		<!-- 缺省页 -->
		<view v-else>
			<u-empty mode="data" icon="/static/recruit/index/qsy.png" width="350" marginTop="150">
			</u-empty>
		</view>
	</view>
</template>

<script>
	import myHead from '@/pages/component/baseHead.vue'
	export default {
		data() {
			return {
				ListData: [],
				obj: {
					Keyword: "", //关键字
					OrderStatus: 20, //订单状态 0待付款 1已取消 10处理中 20交易成功
					UserId: null, //用户ID
					CorpId: null, //企业ID
					PageIndex: 1, //页码
					PageSize: 10, //每页大小
					isCorp:null,// 0查询个人订单 1查询企业订单
				},
				status: 'loadmore',
				isCorpNum:0

			}
		},
		components: {
			myHead,
		},
		computed: {

		},
		onShow() {},
		created() {
			this.dataList()
		},
		onReachBottom() {
			// 加载前值为loadmore，加载中为loading，没有数据为nomore
			if (this.status != "nomore") {
				this.status = "loading";
				this.dataList()
			}
		},
		onPullDownRefresh() {
			this.obj = {
				PageIndex: 1,
				PageSize: 10,
				KeyWord: '',
				isCorp:this.obj.isCorp
			}
			this.dataList()
			uni.stopPullDownRefresh(); //停止刷新
		},
		methods: {
			dataList() {
				const app = getApp();
				if (app.globalData.userRole == 0) {
					this.obj.UserId = app.globalData.user.UserId
					this.obj.isCorp=0
				} else {
					this.obj.CorpId = app.globalData.userCorpId
					this.obj.isCorp=1
				}
				this.$http.huirc.planlist(this.obj).then(res => {
					console.log(res);
					if (res.Success) {
						if (this.obj.PageIndex == 1 && res.Result.Items.length == 0) {
							this.ListData = [];
						} else {
							if (res.Result.Items.length == 0) {
								// 没有数据----
								this.status = "nomore";
								return;
							}
							this.ListData = this.ListData.concat(res.Result.Items).map(item => {
								return {
									...item,
									checked: false
								}
							})

							console.log("itemdds", this.ListData);

						}

						if (res.Result.Items.length >= this.obj.PageSize) {
							this.obj.PageIndex++;
							// 表示还有数据
						} else {
							//没有更多数据了
							this.status = "nomore";
						}
					}
				})
			}
		}
	}
</script>

<style>

</style>
<style scoped lang="scss">
	.content {
		padding: 20rpx 20rpx;

		.card {
			padding: 20rpx 30rpx;
			border-radius: 10rpx;
			margin-bottom: 20rpx;
			background-color: #fff;


			.cardlist {
				display: flex;
				justify-content: space-between;
				padding: 10rpx 0;
				border-bottom: 1rpx solid #E7E7E8;

				.cardbz {
					font-size: 30rpx;
					font-weight: bold;
					color: #000000;
				}

				.cardje {
					font-size: 28rpx;
					font-weight: bold;
					color: #000000;
				}
			}

			.cardtext {
				padding: 10rpx 0;
				font-size: 26rpx;
				font-weight: 400;
				color: #000000;
			}
		}
	}
</style>